/**********************************************************************************
 * Copyright (c) 2012 - 2012,  ObjectPoolLite, All right reserved
 * Title: com.adc.litepool.base  BasePoolableObjectFactory.java 
 * @author shen  shenqiao2012@163.com 
 *  2012-7-31 下午1:53:56 
 *********************************************************************************/


package com.adc.litepool.base;

import com.adc.litepool.PoolableObjectFactory;


/**
 * 
 * Description: 基础池化对象管理工厂抽象类BasePoolableObjectFactory：提供最基本的池化对象管理操作 ;
 * @author shen  shenqiao2012@163.com
 */
public abstract class BasePoolableObjectFactory implements PoolableObjectFactory {

	/**
	 * Description:  
	 * @see com.adc.litepool.PoolableObjectFactory#createObject(java.lang.Class) 
	 */
	@Override
	public Object createObject(Class<?> clsType) {
		Object result=null;
		try {
			result=clsType.newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		return result;
	}

	/**
	 * Description:  
	 * @see com.adc.litepool.PoolableObjectFactory#clearObject(java.lang.Object) 
	 */
	@Override
	public Object clearObject(Object obj) {
		Class<?> clazz=obj.getClass();
		obj=null;
		return createObject(clazz);
	}

	/**
	 * Description:  
	 * @see com.adc.litepool.PoolableObjectFactory#destroyObject(java.lang.Object) 
	 */
	@Override
	public void destroyObject(Object obj) {
		obj=null;
		System.gc();
	}

}
